package org.corpus.english.model;

// Generated 2009/8/14 �U�� 05:49:21 by Hibernate Tools 3.2.4.GA

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * Word generated by hbm2java
 */
@Entity
@Table(name = "word", catalog = "english")
public class Word implements java.io.Serializable {

	private int wordid;
	private String word;
	private String phonetics;
	private String pos;
	private String chinese;
	private String english;
	private String synonyms;
	private String origin;
	private String sentences;
	private String memory;
	private boolean edited;

	private Set<WordCategoryData> wordCategoryDatas = new HashSet<WordCategoryData>(
			0);
	public Word(){
		
	}
	public Word(String string) {
		this.word = string;
	}

	public Word(String word, String pos) {
		this.word = word;
		this.pos = pos;
	}

	public Word(String word, String phonetics, String pos, String chinese,
			String synonyms, String origin, String sentences, String memory,
			Set<WordCategoryData> wordCategoryDatas) {
		this.word = word;
		this.phonetics = phonetics;
		this.pos = pos;
		this.chinese = chinese;
		this.synonyms = synonyms;
		this.origin = origin;
		this.sentences = sentences;
		this.memory = memory;
		this.wordCategoryDatas = wordCategoryDatas;
	}

	/**
	 * @param word2
	 * @param b
	 */
	public Word(String word, boolean edited) {
		this.word = word;
		this.edited = edited;
	}
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "wordid", unique = true, nullable = false)
	public int getWordid() {
		return this.wordid;
	}

	public void setWordid(int wordid) {
		this.wordid = wordid;
	}

	@Column(name = "word", nullable = false, length = 100)
	public String getWord() {
		return this.word;
	}

	public void setWord(String word) {
		this.word = word;
	}

	@Column(name = "phonetics", length = 2000)
	public String getPhonetics() {
		return this.phonetics;
	}

	public void setPhonetics(String phonetics) {
		this.phonetics = phonetics;
	}

	@Column(name = "pos", length = 50)
	public String getPos() {
		return this.pos;
	}

	public void setPos(String pos) {
		this.pos = pos;
	}

	@Column(name = "chinese", length = 250)
	public String getChinese() {
		return this.chinese;
	}

	public void setChinese(String chinese) {
		this.chinese = chinese;
	}

	@Column(name = "english", length = 3000)
	public String getEnglish() {
		return english;
	}
	
	public void setEnglish(String english) {
		this.english = english;
	}
	@Column(name = "synonyms", length = 200)
	public String getSynonyms() {
		return this.synonyms;
	}

	public void setSynonyms(String synonyms) {
		this.synonyms = synonyms;
	}

	@Column(name = "origin", length = 200)
	public String getOrigin() {
		return this.origin;
	}

	public void setOrigin(String origin) {
		this.origin = origin;
	}

	@Column(name = "sentences", length = 3000)
	public String getSentences() {
		return this.sentences;
	}

	public void setSentences(String sentences) {
		this.sentences = sentences;
	}

	@Column(name = "memory", length = 1000)
	public String getMemory() {
		return this.memory;
	}

	public void setMemory(String memory) {
		this.memory = memory;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "word_cateogry", catalog = "english", joinColumns = { @JoinColumn(name = "wordid", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "categoryid", nullable = false, updatable = false) })
	public Set<WordCategoryData> getWordCategoryDatas() {
		return this.wordCategoryDatas;
	}

	public void setWordCategoryDatas(Set<WordCategoryData> wordCategoryDatas) {
		this.wordCategoryDatas = wordCategoryDatas;
	}
	
	@Column(name = "edited")
	public boolean isEdited() {
		return this.edited;
	}

	public void setEdited(boolean edited) {
		this.edited = edited;
	}
	
	@Transient
	public List getWordCategoryDataList(){
		List list = new ArrayList();
		list.addAll(wordCategoryDatas);
		System.out.println(list.get(0));
		return list;
	}

}
